package com.weigee.ktv.v.adapter.rv;

import android.support.annotation.NonNull;
import android.support.v7.widget.AppCompatTextView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.l.d.app.library.adapter.RvListAdapter;
import com.weigee.ktv.R;
import com.weigee.ktv.m.entity.CommonProblemsEntity;
import com.weigee.ktv.m.entity.WrapHolder;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by 林德 on 2017/4/14 11:25.
 * <p/>
 */
public final class CommonProblemsAdapter extends RvListAdapter<CommonProblemsEntity, CommonProblemsAdapter.Holder>
{
    @Override
    public Holder onCreateViewHolder(ViewGroup parent, int viewType)
    {
        final View rootView = LayoutInflater.from(parent.getContext()).inflate(R.layout.commonproblems_frag_rv_item, parent, false);
        return new Holder(rootView);
    }

    @Override
    public void onBindViewHolder(Holder holder, int position)
    {
        final CommonProblemsEntity entity = getItem(position);
        if (entity == null) return;
        holder.tvQuestion.setText(entity.getTitle());
        holder.tvAnswer.setText(entity.getContent());
    }

    @NonNull
    @Override
    public List<CommonProblemsEntity> onCreateNewEmptyList()
    {
        return new ArrayList<>();
    }

    static class Holder extends WrapHolder
    {
        @BindView(R.id.tv_question)
        AppCompatTextView tvQuestion;
        @BindView(R.id.tv_answer)
        AppCompatTextView tvAnswer;

        private Holder(View itemView)
        {
            super(itemView);
        }
    }
}
